/**
 * Copyright (C), 2015-2020, XXX有限公司
 * FileName: MyBeanPostProcessor
 * Author:   ZX
 * Date:     2020/8/9 21:20
 * Description:
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package org.example;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * 〈一句话功能简述〉<br> 
 * 〈测试BeanPostProcessor，通过@Component注解添加到Spring中，在bean-initMethod方法执行前后回调〉
 * @author ZX
 * @create 2020/8/9
 * @since 1.0.0
 */
@Component
public class MyBeanPostProcessor implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if (beanName.equals("helloController")){
            System.out.println("before init method");
        }
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if (beanName.equals("helloController")){
            System.out.println("after init method");
        }
        return bean;
    }
}